package com.ruoyi.abuwx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.abuwx.domain.AbuwxUnitStatistics;
import com.ruoyi.abuwx.service.IAbuwxUnitStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单位统计Controller
 * 
 * @author tang
 * @date 2022-07-02
 */
@RestController
@RequestMapping("/abuwx/AbuwxUnitStatistics")
public class AbuwxUnitStatisticsController extends BaseController
{
    @Autowired
    private IAbuwxUnitStatisticsService abuwxUnitStatisticsService;

    /**
     * 查询单位统计列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(AbuwxUnitStatistics abuwxUnitStatistics)
    {
        startPage();
        List<AbuwxUnitStatistics> list = abuwxUnitStatisticsService.selectAbuwxUnitStatisticsList(abuwxUnitStatistics);
        return getDataTable(list);
    }

    /**
     * 导出单位统计列表
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:export')")
    @Log(title = "单位统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbuwxUnitStatistics abuwxUnitStatistics)
    {
        List<AbuwxUnitStatistics> list = abuwxUnitStatisticsService.selectAbuwxUnitStatisticsList(abuwxUnitStatistics);
        ExcelUtil<AbuwxUnitStatistics> util = new ExcelUtil<AbuwxUnitStatistics>(AbuwxUnitStatistics.class);
        util.exportExcel(response, list, "单位统计数据");
    }

    /**
     * 获取单位统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(abuwxUnitStatisticsService.selectAbuwxUnitStatisticsById(id));
    }

    /**
     * 新增单位统计
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:add')")
    @Log(title = "单位统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AbuwxUnitStatistics abuwxUnitStatistics)
    {
        return toAjax(abuwxUnitStatisticsService.insertAbuwxUnitStatistics(abuwxUnitStatistics));
    }

    /**
     * 修改单位统计
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:edit')")
    @Log(title = "单位统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AbuwxUnitStatistics abuwxUnitStatistics)
    {
        return toAjax(abuwxUnitStatisticsService.updateAbuwxUnitStatistics(abuwxUnitStatistics));
    }

    /**
     * 删除单位统计
     */
    @PreAuthorize("@ss.hasPermi('abuwx:AbuwxUnitStatistics:remove')")
    @Log(title = "单位统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(abuwxUnitStatisticsService.deleteAbuwxUnitStatisticsByIds(ids));
    }
}
